import { ref } from 'vue'
import { getReceiverType } from '@/api/sms'

export default () => {
  // 获取接收者类型加载
  const getReceiverTypeLoading = ref(false)

  // 接收者类型
  const receiverType = ref<ReceiverType | null>(null)

  /**
   * 获取接收者类型
   * @param {String} id - 短信模板id
   */
  const getReceiverTypeBySmsTemplateId = async (id: string) => {
    getReceiverTypeLoading.value = true
    const res = await getReceiverType(id)
    getReceiverTypeLoading.value = false
    receiverType.value = res.data.data.rows
  }

  return {
    receiverType,
    getReceiverTypeLoading,
    getReceiverTypeBySmsTemplateId,
  }
}
